package com.itheima.servlet;

import com.itheima.daomain.Student;
import com.itheima.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/findall")
public class FindAllStudentServlet extends HttpServlet {
    // 获取表单数据


    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //调用service方法
        List<Student> list = null;
        try {
            list = new StudentServiceImpl().findAll();
        } catch (Exception e) {
            e.printStackTrace();
        }
        //设置共享数据请求转发
        req.setAttribute("xxx",list);
        req.getRequestDispatcher("/list.jsp").forward(req,resp);

    }



}
